Write a Rust program to check if a string is an anagram of another string.
Write a Rust program to check if a string is an anagram of another string.
299
20-Jun-2023
Aryan Kumar
23-Jun-2023Rust
This program first checks if the two strings have the same length. If they do, then the program creates two vectors of characters, one for each string. The characters in each vector are then sorted. Finally, the two vectors are compared to see if they are equal. If they are equal, then the two strings are anagrams.
To run this program, you can save it as a .rs file and then compile and run it using the following commands:
Code snippet
This will print the following output:
Code snippet
This indicates that the two strings hello and olleh are anagrams.